﻿namespace Storm.Docking.Visual.Glyphs
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.Text;
    using System.Windows.Forms;

	using Storm;
	using Storm.Docking;
	using Storm.Docking.Controls;
    using Storm.Docking.Visual;
    using Storm.Docking.Visual.Drawing;

    /// <summary>
    /// Represents the close button of a DockCaption.
    /// </summary>
    [ToolboxItem(false)]
    public class CloseGlyph 
        : Glyph
    {
        #region Methods

        #region Internal

        internal override void OnClickAction()
        {
            this.DockCaption.DockPanel.MakeClosed();
        }

        internal override void OnParentRecieveFocus(object sender, EventArgs e)
        {
			if (this.DockCaption.Focused == true)
			{
				this.Image.Image = this.DockCaption.Renderer.
					DockColorTable.CloseGlyphFocusImage;
			}
			else
			{
				this.Image.Image = this.DockCaption.Renderer.
					DockColorTable.CloseGlyphNormalImage;
			}
        }

        internal override void OnParentReleaseFocus(object sender, EventArgs e)
        {
			if (this.DockCaption.Focused == true)
			{
				this.Image.Image = this.DockCaption.Renderer.
					DockColorTable.CloseGlyphFocusImage;
			}
			else
			{
				this.Image.Image = this.DockCaption.Renderer.
					DockColorTable.CloseGlyphNormalImage;
			}
        }

        #endregion

        #endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="CloseGlyph"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
        public CloseGlyph(DockCaption parent)
            : base(parent)
        {
			this.Image.Image = this.DockCaption.Renderer.
				DockColorTable.CloseGlyphNormalImage;
        }
    }
}
